<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width:91px;
            height: 200px;
            margin:10px auto;
        }
        h2{
            text-align: center;
        }
    </style>
    <script>
        var timer;
        window.onload=function(){
            var start=document.getElementById("start");
            var stop=document.getElementById("stop");
            var tds=document.querySelectorAll("td");
            start.onclick=function(){
               clearInterval(timer);
               timer=setInterval(function(){
                   //将表格中所有的td设置成蓝色背景
                    for(var i=0;i<tds.length;i++){
                        tds[i].style.background="lightblue";
                    }
                    // [0-19]   Math.random()*20   [0,20)
                    var n=parseInt(Math.random()*tds.length);
                    tds[n].style.background="hotpink";

               },100);
            };

            stop.onclick=function(){
                clearInterval(timer);
            };

        };
    </script>
</head>
<body>
    <!-- table>tbody>(tr>td{td$$}*5)*4 -->
    <h2>抽奖啦</h2>
    <table border="1" align="center" width="600" height="300" cellspacing="0">
        <tbody align="center">
            <tr>
                <td>td01</td>
                <td>td02</td>
                <td>td03</td>
                <td>td04</td>
                <td>td05</td>
            </tr>
            <tr>
                <td>td01</td>
                <td>td02</td>
                <td>td03</td>
                <td>td04</td>
                <td>td05</td>
            </tr>
       
            <tr>
                <td>td01</td>
                <td>td02</td>
                <td>td03</td>
                <td>td04</td>
                <td>td05</td>
            </tr>
            <tr>
                <td>td01</td>
                <td>td02</td>
                <td>td03</td>
                <td>td04</td>
                <td>td05</td>
            </tr>
        </tbody>
    </table>
    <div>
        <input type="button" value="开始" id="start">
        <input type="button" value="停止" id="stop">
    </div>
</body>
</html>